package com.xiaozhen.rtmp.service;

import com.xiaozhen.rtmp.domain.Camera;
import com.xiaozhen.rtmp.thread.MediaTransfer;
import io.netty.channel.ChannelHandlerContext;

import java.util.concurrent.ConcurrentHashMap;

/**
 * HISTORY
 *
 * @author zhenweisheng
 * @date 2021/12/6 16:29
 * @description:
 */
public interface MediaService {

    /**
     * 缓存流转换线程
     */
    ConcurrentHashMap<String, MediaTransfer> cameras = new ConcurrentHashMap<>();

    /**
     * api播放
     *
     * @param camera
     * @return
     */
    boolean playForApi(Camera camera);

    /**
     * http-flv播放
     *
     * @param cameraDto
     * @param ctx
     */
    void playForHttp(Camera cameraDto, ChannelHandlerContext ctx);

    /**
     * ws-flv播放
     *
     * @param cameraDto
     * @param ctx
     */
    void playForWs(Camera cameraDto, ChannelHandlerContext ctx);

    /**
     * 停止推流
     *
     * @param camera
     */
    void closeForApi(Camera camera);
}
